import { requireAdmin } from "#server/utils/admin-guard"; import { createModel } from "#server/service/llm"; export default defineWrappedResponseHandler(async (event) => { await requireAdmin(event); const providerId = Number(getRouterParam(event, "providerId")); if (!providerId) { return R.throwError(400, "无效的供应商ID", null); } const body = await readBody(event); const { name, modelId, type, enabled, description, maxTokens } = body; if (!name || !modelId) { return R.throwError(422, "模型名称和模型ID不能为空", null); } const result = await createModel({ providerId, name, modelId, type: type || "text", enabled: enabled ?? 1, description, maxTokens, }); return R.success(result); });